package com.itheima.d3_voteMapDemo;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * 我们看下老师的思路
 * 他是将 A=10,B=20这样当成键值对
 */
public class voteTeacher {
    public static void main(String[] args) {
        String[] spots = {"A","B","C","D"};
        Random random = new Random();

        Map<String,Integer> maps = new HashMap<>();
        //{A=20,B=23}
        for (int i = 0; i < 80; i++) {
            int index = random.nextInt(spots.length);
            if(maps.containsKey(spots[index])){
                maps.put(spots[index],maps.get(spots[index])+1);
            }else {
                maps.put(spots[index],1);
            }
        }
        System.out.println(maps);
    }
}
